#include<iostream>
#include<map>
#include<string>
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
string s;
const int N = 2e5 + 10;
map<PII, int>mp;
map<int, int>mp2;
int a[N];
int n;
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	cin >> s;
	s = " " + s;
	for (int i = 1; i <= n; i++) {
		//cout << s[i] << endl;
		if (s[i] == 'R') {
			mp[{1, a[i]}]++;
		}
		else mp[{2, a[i]}]++;
	}
	LL ans = 0;
	for (int i = 1; i <= n; i++) {
		if (!mp2[a[i]]) {
			mp2[a[i]] = 1;
			ans += mp[{1, a[i]}] * mp[{2, a[i]}];
		}
	}
	cout << ans << endl;
	return 0;
}